import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_learn/learn/inherit/Config.dart';
import 'package:flutter_learn/learn/inherit/ConfigWidget.dart';

class ConfigUpdater extends StatelessWidget {
  const ConfigUpdater({Key? key, this.onColorChanged, this.onFontSizeIncreased}) : super(key: key);

  final ValueChanged<Color?>? onColorChanged;
  final VoidCallback? onFontSizeIncreased;
  static const List<Color> _colors = [Colors.red, Colors.green, Colors.blue];

  @override
  Widget build(BuildContext context) {
    print("重新构建＝＝＝＞ConfigUpdater");
    Config config = Config();
    return Column(
      children: [
        DropdownButton(
          value: config.color,
          items: _colors.map((color) {
            return DropdownMenuItem(
              value: color,
              child: Text(color.toString()),
            );
          }).toList(),
          onChanged: onColorChanged,
        ),
        ElevatedButton(onPressed: onFontSizeIncreased, child: Text('Increase font size'))
      ],
    );
  }
}
